package com.cadre.basic.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestThread {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyThread t1 = new MyThread();
        t1.setName("线程1");
        t1.start();

        MyThread t2 = new MyThread();
        t2.setName("线程2");
        t2.start();

        System.out.println("=============================");

        MyRun myRun = new MyRun();

        Thread r1 = new Thread(myRun);
        r1.setName("线程3");
        r1.start();

        Thread r2 = new Thread(myRun);
        r2.setName("线程4");
        r2.start();


        System.out.println("=============================");

        MyCallable mc = new MyCallable();
        FutureTask<Integer> ft = new FutureTask<>(mc);

        Thread m1 = new Thread(ft);
        m1.start();
        Integer result = ft.get();

        System.out.println(result);


    }
}
